package com.juicygames.framework.gamepart;

import com.juicygames.framework.GameAction;

public abstract class GameHandler<ActionTypeParam extends GameAction> extends GameComponent {
	
	public abstract void handle(ActionTypeParam action);
	
	public boolean handlesClass(GameAction action) {
		Class<? extends GameAction> actionClass = action.getClass();
		return actionClass.equals(getActionClassHandled());
	}
	
	public void groundHandler() {
		if (parent != null) {
			parent.groundHandler(this);
		}
	} 
	
	public GamePart getParent() {
		return parent;
	}
	
	public abstract Class<ActionTypeParam> getActionClassHandled();

	public GamePart getSelf() {
		return parent;
	}

}
